Skip to content

[Fix] Tasks keep retrying when provider billing fails - #509

Merged
mrubens merged 2 commits into
developfrom
codex/terminate-provider-billing-retries
Jul 18, 2026
Merged

[Fix] Tasks keep retrying when provider billing fails#509
mrubens merged 2 commits into
developfrom
codex/terminate-provider-billing-retries

Conversation

@mrubens

@mrubens mrubens commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Opened on behalf of Matt Rubens. View the task or mention @roomote-roomote for follow-up asks.

What changed

When a provider reports a billing, suspension, or payment-required failure as a retryable OpenCode session status, the worker now treats it as terminal: it aborts the OpenCode retry loop, surfaces the provider message, clears queued prompts, and ends the task. Message-only retry statuses such as bare Payment required (no status code or error code) are classified the same way, matching how handleSessionStatus actually invokes the classifier.

Transient provider failures continue to use the existing retry/backoff behavior.

Why this change was made

Some providers mark account or billing failures as retryable. OpenCode then enters unbounded backoff while the task sits in a retry loop that cannot succeed. Roomote needs to recognize those failures from the status payload it actually receives—including message-only forms—and fail the task cleanly instead.

Impact

Tasks that hit terminal provider billing errors stop sooner with a clear provider message, instead of spinning on retries. Ordinary transient provider errors still retry as before. No UI changes.

@roomote-roomote

roomote-roomote Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

No new code issues found. See task

  • apps/worker/src/sandbox-server/lib/harnesses/opencode-server/provider-error-recovery.ts:153 handleSessionStatus calls this classifier with only { message }, so the 402/payment_required fields covered by the new test are unavailable. A retry status whose message is simply Payment required is not matched by the string checks and therefore stays in OpenCode's retry loop, contrary to the stated payment-required behavior. Match that message-only form (and add a retry-status regression test).

Reviewed a085b5e

@mrubens

mrubens commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

@roomote-roomote address PR comment

@roomote-roomote

Copy link
Copy Markdown
Contributor

I'm on it. I started a dedicated PR follow-up task for this request, and I'll keep updates here. See task

@roomote-roomote

roomote-roomote Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Fixed the outstanding review item: bare Payment required retry statuses are now terminal, with unit + harness regression coverage. Pushed in a085b5e. See task

Revert this commit

Classify bare "Payment required" retry status messages as terminal so
OpenCode does not keep backoff when only the status message is available.
@roomote-roomote roomote-roomote Bot changed the title Stop retrying terminal provider billing errors [Fix] Tasks keep retrying when provider billing fails Jul 18, 2026
@mrubens
mrubens marked this pull request as ready for review July 18, 2026 03:51
@mrubens
mrubens merged commit 25de695 into develop Jul 18, 2026
18 checks passed
@mrubens
mrubens deleted the codex/terminate-provider-billing-retries branch July 18, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant